using System.Collections.Generic;
using Kotonoha.Server.Objects.Model;
using NHibernate;
using NHibernate.Criterion;
using System.Linq;

namespace Kotonoha.Server.Db.Dao {
    public class ModelDao : DaoBase {
        public ModelDao(ISession session) : base(session) {}

        public bool existKanji(string ch) {
            ICriteria cr = session.CreateCriteria(typeof (Kanji));
            cr.Add(Restrictions.Eq("Character", ch));
            cr.SetProjection(Projections.Count("Id"));
            return cr.UniqueResult<int>() == 1;
        }

        public List<Kanji> findAllKanji(ICollection<string> chs) {
            ICriteria cr = session.CreateCriteria(typeof(Kanji));
            cr.Add(Restrictions.InG("Character", chs));
            return cr.List<Kanji>().ToList();
        }
    }
}